<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .message-box {
            width: 300px;
            padding: 10px 20px;
            color: white;
            background: rgb(2, 214, 133);
        }

        .message-box-close {
            float: right;
            color: white;
        }
    </style>
</head>

<body>
    <div id="app">
        <message-box :show.sync="isShow">{{msg}}</message-box>
    </div>
    <script src="../assets/vue2.js"></script>
    <script>
        Vue.component('message-box', {
            props: ['show'],
            template: `
            <div class="message-box" v-show="show">
                <!-- 相当于占位符 -->
                <slot></slot>
                <span class="message-box-close" @click="$emit('update:show',false)">X</span>
            </div>`
        })
        const app = new Vue({
            el: '#app',
            data() {
                return {
                    isShow: true, // 是否显示弹框
                    msg: '操作成功！' // 弹框提示内容
                }
            },
        })
    </script>
</body>

</html>